#!/bin/bash

if [ "$DESCRIBE_TEST" = 1 ] ; then
	echo "NO DESCRIPTION FOR THIS TEST!"
        exit
fi

set -euox pipefail

source "./test/lib.include"

run_test cargo run identity new --no-domain
IDENT=$(grep IDENTITY "$TEST_OUT" | awk '{print $2}')
EMAIL="$(random_string)@clockworklabs.io"
TOKEN=$(grep token "$HOME/.spacetime/config.toml" | awk '{print $3}' | tr -d \')

reset_config

run_test cargo run identity add "$IDENT" "$TOKEN"
run_test cargo run identity set-default "$IDENT"
[ "$IDENT" == "$(grep IDENTITY "$TEST_OUT" | awk '{print $2}')" ]

reset_config

run_test cargo run identity new --no-domain

run_test cargo run publish
ADDRESS="$(grep "reated new database" "$TEST_OUT" | awk 'NF>1{print $NF}')"
